import { View } from "../../../mvc/core/View";
import { LayerManager } from "../../manager/LayerManager";
import { SpaInteractButton } from "./cell/SpaInteractButton";
import { ESpringInteractType } from "../../../../Message/Game/ESpringInteractType";
import { Cache } from "../../cache/Cache";
import { SSpringInteractCount } from "../../../../Message/Game/SSpringInteractCount";
import { GameConst } from "../../../component/gconst/GameConst";
//class SpaInteractPanel
    
    export  class SpaInteractPanel extends View
    {
        constructor()
        {
            super();
            this.layer = LayerManager.uiLayer;
            this.createChildren();
            this.addListeners();
            return;
        }

        /* internal  */createChildren(): void
        {
            this._giveSoapBtn = new SpaInteractButton();
            this._giveSoapBtn.type = ESpringInteractType._ESpringInteractTypeSoap;
            this._giveSoapBtn.x = -70;
            this._giveSoapBtn.y = 0;
            this.addChild(this._giveSoapBtn);
            this._rubBackBtn = new SpaInteractButton();
            this._rubBackBtn.type = ESpringInteractType._ESpringInteractTypeRubback;
            this._rubBackBtn.x = 0;
            this._rubBackBtn.y = 0;
            this.addChild(this._rubBackBtn);
            this._rubDownBtn = new SpaInteractButton();
            this._rubDownBtn.type = ESpringInteractType._ESpringInteractTypeRubdown;
            this._rubDownBtn.x = 70;
            this._rubDownBtn.y = 0;
            this.addChild(this._rubDownBtn);
            this._leaveBtn = new SpaInteractButton();
            this._leaveBtn.type = -1;
            this._leaveBtn.x = 140;
            this._leaveBtn.y = 0;
            this.addChild(this._leaveBtn);
            return;
        }

        /* internal  */addListeners(): void
        {
            return;
        }

        public setLastClickTime(): void
        {
            if (Cache.instance.spa.interactType != ESpringInteractType._ESpringInteractTypeRubback) 
            {
                if (Cache.instance.spa.interactType != ESpringInteractType._ESpringInteractTypeRubdown) 
                {
                    if (Cache.instance.spa.interactType == ESpringInteractType._ESpringInteractTypeSoap) 
                    {
                        this._giveSoapBtn.updateClickTime();
                    }
                }
                else 
                {
                    this._rubDownBtn.updateClickTime();
                }
            }
            else 
            {
                this._rubBackBtn.updateClickTime();
            }
            return;
        }

        public setNumLabel(arg1: SSpringInteractCount): void
        {
            var loc1=GameConst.SpringRubbackLimit - arg1.rubback;
            var loc2=GameConst.SpringRubdownLimit - arg1.rubdown;
            var loc3=GameConst.SpringSoapLimit - arg1.soap;
            this._rubBackBtn.setNumLabel(loc1);
            this._rubDownBtn.setNumLabel(loc2);
            this._giveSoapBtn.setNumLabel(loc3);
            var loc4=Cache.instance.spa.rubBackTimes;
            var loc5=Cache.instance.spa.rubDownTimes;
            var loc6=Cache.instance.spa.giveSoupTimes;
            if (loc4 < arg1.rubback && loc1 > 0 && !arg1.enterSpring) 
            {
                this._rubBackBtn.startCountDown();
            }
            if (loc5 < arg1.rubdown && loc2 > 0 && !arg1.enterSpring) 
            {
                this._rubDownBtn.startCountDown();
            }
            if (loc6 < arg1.soap && loc3 > 0 && !arg1.enterSpring) 
            {
                this._giveSoapBtn.startCountDown();
            }
            Cache.instance.spa.rubBackTimes = arg1.rubback;
            Cache.instance.spa.rubDownTimes = arg1.rubdown;
            Cache.instance.spa.giveSoupTimes = arg1.soap;
            return;
        }

        /* internal */ /* var */_giveSoapBtn: SpaInteractButton;

        /* internal */ /* var */_rubBackBtn: SpaInteractButton;

        /* internal */ /* var */_rubDownBtn: SpaInteractButton;

        /* internal */ /* var */_leaveBtn: SpaInteractButton;
    }
